package com.example.ioc.conditional.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class OracleCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        try {
            // 根据oracle的核心包扫描是否有依赖
            context.getClassLoader().loadClass("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e) {
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }
}
